/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.z100h.supplychain.customer.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.z100h.supplychain.customer.entity.CustomerStockroom;
import com.z100h.supplychain.customer.mapper.CustomerStockroomMapper;

/**
 * 客户仓库Service
 * @author fyh
 * @version 2019-04-22
 */
@Service
@Transactional(readOnly = true)
public class CustomerStockroomService extends CrudService<CustomerStockroomMapper, CustomerStockroom> {

	@Autowired
	private CustomerStockroomMapper customerStockroomMapper;

	@Override
	public CustomerStockroom get(String id) {
		return super.get(id);
	}

	public CustomerStockroom findByStockroomId(String stockroomId) {
		return customerStockroomMapper.findByStockroomId(stockroomId);
	}

	@Override
	public List<CustomerStockroom> findList(CustomerStockroom customerStockroom) {
		return super.findList(customerStockroom);
	}

	@Override
	public Page<CustomerStockroom> findPage(Page<CustomerStockroom> page, CustomerStockroom customerStockroom) {
		return super.findPage(page, customerStockroom);
	}

	@Override
	@Transactional(readOnly = false)
	public void save(CustomerStockroom customerStockroom) {
		super.save(customerStockroom);
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(CustomerStockroom customerStockroom) {
		super.delete(customerStockroom);
	}

	public void updateRepairStockoutId(String stockroomId, String evidenceId) {
		customerStockroomMapper.updateRepairStockoutId(stockroomId, evidenceId);
	}

	@Deprecated
	public List<String> findRepairIdsByStockroomId(String stockroomId) {
		return customerStockroomMapper.findRepairIdsByStockroomId(stockroomId);
	}

	public Page<CustomerStockroom> findNeedProduceByPage(Page<CustomerStockroom> page,
			CustomerStockroom customerStockroom) {
		dataRuleFilter(customerStockroom);
		customerStockroom.preInsert();
		customerStockroom.setPage(page);
		page.setList(customerStockroomMapper.findNeedProduce(customerStockroom));
		return page;
	}

	public CustomerStockroom getCustomerStockroomByOrderId(String orderId) {
		return customerStockroomMapper.getCustomerStockroomByOrderId(orderId);
	}

	public CustomerStockroom getProjectIdByStockroomId(String stockroomId) {
		return customerStockroomMapper.getProjectIdByStockroomId(stockroomId);
	}

	public String getCustomerIdByStockroomId(String stockroomId) {
		return customerStockroomMapper.getCustomerIdByStockroomId(stockroomId);
	}
}